package com.nbsaas.boot.project.rest.convert;

import com.nbsaas.boot.project.api.domain.simple.ProjectCatalogSimple;
import com.nbsaas.boot.project.data.entity.ProjectCatalog;
import com.nbsaas.boot.rest.api.Converter;

/**
 * 项目分类-列表对象转换器
 */

public class ProjectCatalogSimpleConvert implements Converter<ProjectCatalogSimple, ProjectCatalog> {


    @Override
    public ProjectCatalogSimple convert(ProjectCatalog source) {
        ProjectCatalogSimple result = new ProjectCatalogSimple();


        try {
            if (source.getParent() != null) {
                result.setParent(source.getParent().getId());
            }
        } catch (Exception ignored) {
        }


        try {
            if (source.getParent() != null) {
                result.setParentName(source.getParent().getName());
            }
        } catch (Exception ignored) {
        }

        result.setCode(source.getCode());
        result.setDepth(source.getDepth());
        result.setName(source.getName());
        result.setIds(source.getIds());
        result.setSortNum(source.getSortNum());
        result.setId(source.getId());
        result.setLft(source.getLft());
        result.setAddDate(source.getAddDate());
        result.setRgt(source.getRgt());
        result.setLastDate(source.getLastDate());


        return result;
    }

}